package com.mycjj.android.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.mycjj.android.R;
import com.mycjj.android.bean.StoreBaseBean.Store;

public class StoreAdapter extends TAdapter<Store> {

	public StoreAdapter(Context mContext) {
		super(mContext);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			convertView = LayoutInflater.from(mContext).inflate(
					R.layout.item_select_store_view, null);
			holder = new ViewHolder();
			holder.pic = (ImageView) convertView
					.findViewById(R.id.header_pic);
			holder.tv_name = (TextView) convertView
					.findViewById(R.id.tv_name);
			holder.tv_address = (TextView) convertView
					.findViewById(R.id.tv_address);
			holder.tv_distance = (TextView) convertView
					.findViewById(R.id.tv_distance);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		Store store = mList.get(position);
		if (store != null) {
			Log.e("mark", "store.toString:" + store.toString());
//			imageLoader.displayImage(store.getStore_logo(), holder.pic);
			imageLoader1.displayImage(store.getStore_logo(), holder.pic,options,animateFirstListener);
			holder.tv_name.setText(store.getStore_name());
			holder.tv_address.setText(store.getStore_address());
			if(store.getStore_distance() == -1.0){
				holder.tv_distance.setText("未知");
			}else{
				holder.tv_distance.setText(String.valueOf(store.getStore_distance())+"km");
			}
			
		}

		return convertView;
	}

	class ViewHolder {
		ImageView pic;
		TextView tv_name;
		TextView tv_address;
		TextView tv_distance;
	}
}
